home *** CD-ROM | disk | FTP | other *** search
- using System;
- using System.Collections;
- using System.Collections.Specialized;
- using System.IO;
- using System.Reflection;
- using System.Xml;
- using System.Web;
- using Microsoft.Win32;
- using GBPVR.Public;
-
- using IPNumbers;
-
- namespace gbweb
- {
- /// <summary>
- /// Summary description for Settings.
- /// </summary>
- public class Settings
- {
- public bool autoShowSearch = false;
- public bool autoShowRecord = false;
- public double autoSearchDays = 2;
- public string lastAutoSearchDate = string.Empty;
- public string reminder = "2";
- public string guideStartTime = "";
- public string schedule = "GBPVR";
- public string recordingQuality = "Medium";
- public bool showTVGuide = true;
- public bool showManage = true;
- public bool showSearch = true;
- public bool showMusicLib = true;
- public bool showVideoLib = true;
- public bool showPhotoLib = true;
- public bool showStats = true;
- public bool showSubtitle = true;
- public bool showDescription = true;
- public string showGenre = "singleGenre";
- public bool showRating = true;
- public bool showNew = true;
- public bool showHD = true;
- public bool showIMDB = true;
- public bool showNetflix = true;
- public bool showTVCom = true;
- public bool showWiki = true;
- public bool showCredits = true;
- public bool showAirDate = true;
- public bool showStarRating = true;
- public string channelIconExtensions = "jpg,png,gif";
- public string playlistExtension = "m3u";
- public string photoFiles = @"^.*\.(gif|jpg|jpeg|bmp|wmf|png)$";
- public string musicFiles = @"^.*\.(mp3|wav|ogg|wma|ape|m4a|mkv)$";
- public string videoFiles = @"^.*\.(mpeg|mpg|m2v|avi|ogm|mp4|wmv|iso|divx|rm|dvr-ms)$";
- public string coverFiles = @"^(~|cover|folder|default|albumart)\.(jpg|gif|png|bmp)$";
- public string autologinNetworks = "127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16";
- public string GuestUser = "";
- public string GuestPassword = "";
- public string CurrentSearchVersion = "2.0";
-
- //VLC Profile 1 Default Settings
- public string strmPlayer = "VLC";
- public bool strmExternal = true;
-
- public string strmVLCLoc = "C:\\Program Files\\VideoLAN\\Vlc\\";
- public int strmPort = 7648;
- public int strmBuffer = 5000;
- public string strmPriority = "BelowNormal";
- public string strmSetting = "0";
- public int strmBitRate = 0;
- public string strmVideoSizeOpt = "preset";
- public string strmVideoSize = "320x213";
- public string strmVideoScaleSize = "01.00";
-
- public string strmMux = "ts";
- public string strmVideo = "mpg4";
- public string strmAudio = "mp4v";
- public string strmAudoBitrate = "32";
- public string strmAudioChannels = "2";
- public string strmVEncoder = "default";
-
- public string strmH264KeyInt = "";
- public string strmH264IDRInt = "";
- public string strmH264BFrames = "";
- public string strmH264QuantizerParam = "";
- public string strmH264QuantizerMax = "";
- public string strmH264QuantizerMin = "";
- public bool strmH264CABAC = true;
- public bool strmH264LoopFilter = true;
- public bool strmH264Analyse = false;
- public string strmH264FrameRef = "";
- public string strmH264Adapt = "none";
- public string strmH264Me = "dia";
- public string strmH264SubME = "1";
- public string strmH264ChromaME = "none";
- public string strmH264MERange = "1";
-
- //VLC Profile 2 Default Settings
- public string strmPlayer2 = "VLC";
- public bool strmExternal2 = true;
-
- public string strmVLCLoc2 = "C:\\Program Files\\VideoLAN\\Vlc\\";
- public int strmPort2 = 7648;
- public int strmBuffer2 = 5000;
- public string strmPriority2 = "BelowNormal";
- public string strmSetting2 = "0";
- public int strmBitRate2 = 0;
- public string strmVideoSizeOpt2 = "preset";
- public string strmVideoSize2 = "320x213";
- public string strmVideoScaleSize2 = "01.00";
-
- public string strmMux2 = "ts";
- public string strmVideo2 = "mpg4";
- public string strmAudio2 = "mp3";
- public string strmAudoBitrate2 = "128";
- public string strmAudioChannels2 = "2";
- public string strmVEncoder2 = "default";
-
- public string strmH264KeyInt2 = "";
- public string strmH264IDRInt2 = "";
- public string strmH264BFrames2 = "";
- public string strmH264QuantizerParam2 = "";
- public string strmH264QuantizerMax2 = "";
- public string strmH264QuantizerMin2 = "";
- public bool strmH264CABAC2 = true;
- public bool strmH264LoopFilter2 = true;
- public bool strmH264Analyse2 = false;
- public string strmH264FrameRef2 = "";
- public string strmH264Adapt2 = "none";
- public string strmH264Me2 = "dia";
- public string strmH264SubME2 = "1";
- public string strmH264ChromaME2 = "none";
- public string strmH264MERange2 = "1";
-
- [NonSerialized()]
- public IPList autologinNets;
-
- public Settings()
- {
- //
- // TODO: Add constructor logic here
- //
- Load();
- }
-
- private void Load()
- {
- string value;
- DateTime tmpDate = DateTime.Now.AddDays(-1);
- lastAutoSearchDate = tmpDate.ToShortDateString();
- value = GetSetting(this, "CurrentSearchVersion"); if ((value != null) && (value.Length > 0)) CurrentSearchVersion = value;
- value = GetSetting(this, "autoShowSearch"); if ((value != null) && (value.Length > 0)) autoShowSearch = Convert.ToBoolean(value);
- value = GetSetting(this, "autoShowRecord"); if ((value != null) && (value.Length > 0)) autoShowRecord = Convert.ToBoolean(value);
- value = GetSetting(this, "autoSearchDays"); if ((value != null) && (value.Length > 0)) autoSearchDays = Convert.ToDouble(value);
- value = GetSetting(this, "lastAutoSearchDate"); if ((value != null) && (value.Length > 0)) lastAutoSearchDate = value;
- value = GetSetting(this, "showTVGuide"); if ((value != null) && (value.Length > 0)) showTVGuide = Convert.ToBoolean(value);
- value = GetSetting(this, "showManage"); if ((value != null) && (value.Length > 0)) showManage = Convert.ToBoolean(value);
- value = GetSetting(this, "showSearch"); if ((value != null) && (value.Length > 0)) showSearch = Convert.ToBoolean(value);
- value = GetSetting(this, "showMusicLib"); if ((value != null) && (value.Length > 0)) showMusicLib = Convert.ToBoolean(value);
- value = GetSetting(this, "showVideoLib"); if ((value != null) && (value.Length > 0)) showVideoLib = Convert.ToBoolean(value);
- value = GetSetting(this, "showPhotoLib"); if ((value != null) && (value.Length > 0)) showPhotoLib = Convert.ToBoolean(value);
- value = GetSetting(this, "showStats"); if ((value != null) && (value.Length > 0)) showStats = Convert.ToBoolean(value);
- value = GetSetting(this, "reminder"); if ((value != null) && (value.Length > 0)) reminder = value;
- value = GetSetting(this, "guideStartTime"); if ((value != null) && (value.Length > 0)) guideStartTime = value;
- value = GetSetting(this, "schedule"); if ((value != null) && (value.Length > 0)) schedule = value;
- value = GetSetting(this, "recordingQuality"); if ((value != null) && (value.Length > 0)) recordingQuality = value;
- value = GetSetting(this, "showDescription"); if ((value != null) && (value.Length > 0)) showDescription = Convert.ToBoolean(value);
- value = GetSetting(this, "showSubtitle"); if ((value != null) && (value.Length > 0)) showSubtitle = Convert.ToBoolean(value);
- value = GetSetting(this, "showGenre"); if ((value != null) && (value.Length > 0)) showGenre = value;
- if (showGenre.ToLower() == "true") showGenre = "singleGenre";
- if (showGenre.ToLower() == "false") showGenre = "noGenre";
- value = GetSetting(this, "showRating"); if ((value != null) && (value.Length > 0)) showRating = Convert.ToBoolean(value);
- value = GetSetting(this, "showNew"); if ((value != null) && (value.Length > 0)) showNew = Convert.ToBoolean(value);
- value = GetSetting(this, "showHD"); if ((value != null) && (value.Length > 0)) showHD = Convert.ToBoolean(value);
- value = GetSetting(this, "showIMDB"); if ((value != null) && (value.Length > 0)) showIMDB = Convert.ToBoolean(value);
- value = GetSetting(this, "showNetflix"); if ((value != null) && (value.Length > 0)) showNetflix = Convert.ToBoolean(value);
- value = GetSetting(this, "showTVCom"); if ((value != null) && (value.Length > 0)) showTVCom = Convert.ToBoolean(value);
- value = GetSetting(this, "showWiki"); if ((value != null) && (value.Length > 0)) showWiki = Convert.ToBoolean(value);
- value = GetSetting(this, "showCredits"); if ((value != null) && (value.Length > 0)) showCredits = Convert.ToBoolean(value);
- value = GetSetting(this, "showAirDate"); if ((value != null) && (value.Length > 0)) showAirDate = Convert.ToBoolean(value);
- value = GetSetting(this, "showStarRating"); if ((value != null) && (value.Length > 0)) showStarRating = Convert.ToBoolean(value);
- value = GetSetting(this, "playlistExtnesion"); if ((value != null) && (value.Length > 0)) playlistExtension = value;
- value = GetSetting(this, "autologinNetworks"); if ((value != null) && (value.Length > 0)) autologinNetworks = value;
- value = GetSetting(this, "GuestUser"); if ((value != null) && (value.Length > 0)) GuestUser = value;
- value = GetSetting(this, "GuestPassword"); if ((value != null) && (value.Length > 0)) GuestPassword = value;
-
- value = GetSetting(this, "strmPlayer"); if ((value != null) && (value.Length > 0)) strmPlayer = value;
- value = GetSetting(this, "stremExternal"); if ((value != null) && (value.Length > 0)) strmExternal = Convert.ToBoolean(value);
- value = GetSetting(this, "strmVLCLoc"); if ((value != null) && (value.Length > 0)) strmVLCLoc = value;
- value = GetSetting(this, "strmPort"); if ((value != null) && (value.Length > 0)) strmPort = Convert.ToInt32(value);
- value = GetSetting(this, "strmBuffer"); if ((value != null) && (value.Length > 0)) strmBuffer = Convert.ToInt32(value);
- value = GetSetting(this, "strmPriority"); if ((value != null) && (value.Length > 0)) strmPriority = value;
- value = GetSetting(this, "strmBitRate"); if ((value != null) && (value.Length > 0)) strmBitRate = Convert.ToInt32(value);
- value = GetSetting(this, "strmVideoSizeOpt"); if ((value != null) && (value.Length > 0)) strmVideoSizeOpt = value;
- value = GetSetting(this, "strmVideoSize"); if ((value != null) && (value.Length > 0)) strmVideoSize = value;
- value = GetSetting(this, "strmVideoScaleSize"); if ((value != null) && (value.Length > 0)) strmVideoScaleSize = value;
- value = GetSetting(this, "strmSetting"); if ((value != null) && (value.Length > 0)) strmSetting = value;
- value = GetSetting(this, "strmMux"); if ((value != null) && (value.Length > 0)) strmMux = value;
- value = GetSetting(this, "strmVideo"); if ((value != null) && (value.Length > 0)) strmVideo = value;
- value = GetSetting(this, "strmAudio"); if ((value != null) && (value.Length > 0)) strmAudio = value;
- value = GetSetting(this, "strmAudoBitrate"); if ((value != null) && (value.Length > 0)) strmAudoBitrate = value;
- value = GetSetting(this, "strmAudioChannels"); if ((value != null) && (value.Length > 0)) strmAudioChannels = value;
- value = GetSetting(this, "strmVEncoder"); if ((value != null) && (value.Length > 0)) strmVEncoder = value;
- value = GetSetting(this, "strmH264KeyInt"); if ((value != null) && (value.Length > 0)) strmH264KeyInt = value;
- value = GetSetting(this, "strmH264IDRInt"); if ((value != null) && (value.Length > 0)) strmH264IDRInt = value;
- value = GetSetting(this, "strmH264BFrames"); if ((value != null) && (value.Length > 0)) strmH264BFrames = value;
- value = GetSetting(this, "strmH264QuantizerParam"); if ((value != null) && (value.Length > 0)) strmH264QuantizerParam = value;
- value = GetSetting(this, "strmH264QuantizerMax"); if ((value != null) && (value.Length > 0)) strmH264QuantizerMax = value;
- value = GetSetting(this, "strmH264QuantizerMin"); if ((value != null) && (value.Length > 0)) strmH264QuantizerMin = value;
- value = GetSetting(this, "strmH264CABAC"); if ((value != null) && (value.Length > 0)) strmH264CABAC = Convert.ToBoolean(value);
- value = GetSetting(this, "strmH264LoopFilter"); if ((value != null) && (value.Length > 0)) strmH264LoopFilter = Convert.ToBoolean(value);
- value = GetSetting(this, "strmH264Analyse"); if ((value != null) && (value.Length > 0)) strmH264Analyse = Convert.ToBoolean(value);
- value = GetSetting(this, "strmH264FrameRef"); if ((value != null) && (value.Length > 0)) strmH264FrameRef = value;
- value = GetSetting(this, "strmH264Adapt"); if ((value != null) && (value.Length > 0)) strmH264Adapt = value;
- value = GetSetting(this, "strmH264Me"); if ((value != null) && (value.Length > 0)) strmH264Me = value;
- value = GetSetting(this, "strmH264SubME"); if ((value != null) && (value.Length > 0)) strmH264SubME = value;
- value = GetSetting(this, "strmH264ChromaME"); if ((value != null) && (value.Length > 0)) strmH264ChromaME = value;
- value = GetSetting(this, "strmH264MERange"); if ((value != null) && (value.Length > 0)) strmH264MERange = value;
-
- value = GetSetting(this, "strmPlayer2"); if ((value != null) && (value.Length > 0)) strmPlayer2 = value;
- value = GetSetting(this, "stremExternal2"); if ((value != null) && (value.Length > 0)) strmExternal2 = Convert.ToBoolean(value);
- value = GetSetting(this, "strmVLCLoc2"); if ((value != null) && (value.Length > 0)) strmVLCLoc2 = value;
- value = GetSetting(this, "strmPort2"); if ((value != null) && (value.Length > 0)) strmPort2 = Convert.ToInt32(value);
- value = GetSetting(this, "strmBuffer2"); if ((value != null) && (value.Length > 0)) strmBuffer2 = Convert.ToInt32(value);
- value = GetSetting(this, "strmPriority2"); if ((value != null) && (value.Length > 0)) strmPriority2 = value;
- value = GetSetting(this, "strmBitRate2"); if ((value != null) && (value.Length > 0)) strmBitRate2 = Convert.ToInt32(value);
- value = GetSetting(this, "strmVideoSizeOpt2"); if ((value != null) && (value.Length > 0)) strmVideoSizeOpt2 = value;
- value = GetSetting(this, "strmVideoSize2"); if ((value != null) && (value.Length > 0)) strmVideoSize2 = value;
- value = GetSetting(this, "strmVideoScaleSize2"); if ((value != null) && (value.Length > 0)) strmVideoScaleSize2 = value;
- value = GetSetting(this, "strmSetting2"); if ((value != null) && (value.Length > 0)) strmSetting2 = value;
- value = GetSetting(this, "strmMux2"); if ((value != null) && (value.Length > 0)) strmMux2 = value;
- value = GetSetting(this, "strmVideo2"); if ((value != null) && (value.Length > 0)) strmVideo2 = value;
- value = GetSetting(this, "strmAudio2"); if ((value != null) && (value.Length > 0)) strmAudio2 = value;
- value = GetSetting(this, "strmAudoBitrate2"); if ((value != null) && (value.Length > 0)) strmAudoBitrate2 = value;
- value = GetSetting(this, "strmAudioChannels2"); if ((value != null) && (value.Length > 0)) strmAudioChannels2 = value;
- value = GetSetting(this, "strmVEncoder2"); if ((value != null) && (value.Length > 0)) strmVEncoder2 = value;
- value = GetSetting(this, "strmH264KeyInt2"); if ((value != null) && (value.Length > 0)) strmH264KeyInt2 = value;
- value = GetSetting(this, "strmH264IDRInt2"); if ((value != null) && (value.Length > 0)) strmH264IDRInt2 = value;
- value = GetSetting(this, "strmH264BFrames2"); if ((value != null) && (value.Length > 0)) strmH264BFrames2 = value;
- value = GetSetting(this, "strmH264QuantizerParam2"); if ((value != null) && (value.Length > 0)) strmH264QuantizerParam2 = value;
- value = GetSetting(this, "strmH264QuantizerMax2"); if ((value != null) && (value.Length > 0)) strmH264QuantizerMax2 = value;
- value = GetSetting(this, "strmH264QuantizerMin2"); if ((value != null) && (value.Length > 0)) strmH264QuantizerMin2 = value;
- value = GetSetting(this, "strmH264CABAC2"); if ((value != null) && (value.Length > 0)) strmH264CABAC2 = Convert.ToBoolean(value);
- value = GetSetting(this, "strmH264LoopFilter2"); if ((value != null) && (value.Length > 0)) strmH264LoopFilter2 = Convert.ToBoolean(value);
- value = GetSetting(this, "strmH264Analyse2"); if ((value != null) && (value.Length > 0)) strmH264Analyse2 = Convert.ToBoolean(value);
- value = GetSetting(this, "strmH264FrameRef2"); if ((value != null) && (value.Length > 0)) strmH264FrameRef2 = value;
- value = GetSetting(this, "strmH264Adapt2"); if ((value != null) && (value.Length > 0)) strmH264Adapt2 = value;
- value = GetSetting(this, "strmH264Me2"); if ((value != null) && (value.Length > 0)) strmH264Me2 = value;
- value = GetSetting(this, "strmH264SubME2"); if ((value != null) && (value.Length > 0)) strmH264SubME2 = value;
- value = GetSetting(this, "strmH264ChromaME2"); if ((value != null) && (value.Length > 0)) strmH264ChromaME2 = value;
- value = GetSetting(this, "strmH264MERange2"); if ((value != null) && (value.Length > 0)) strmH264MERange2 = value;
-
- string[] invalidAutologinNetworks = ParseAutologinNetworks();
- if (invalidAutologinNetworks.Length > 0)
- {
- Logger.Warning("Invalid autologinNetworks: " + string.Join(",", invalidAutologinNetworks));
- }
- }
-
- public void Save()
- {
- SetSetting(this, "CurrentSearchVersion", CurrentSearchVersion);
- SetSetting(this, "autoShowSearch", autoShowSearch.ToString());
- SetSetting(this, "autoShowRecord", autoShowRecord.ToString());
- SetSetting(this, "autoSearchDays", autoSearchDays.ToString());
- SetSetting(this, "lastAutoSearchDate", lastAutoSearchDate);
- SetSetting(this, "showTVGuide", showTVGuide.ToString());
- SetSetting(this, "showManage", showManage.ToString());
- SetSetting(this, "showSearch", showSearch.ToString());
- SetSetting(this, "showMusicLib", showMusicLib.ToString());
- SetSetting(this, "showVideoLib", showVideoLib.ToString());
- SetSetting(this, "showPhotoLib", showPhotoLib.ToString());
- SetSetting(this, "showStats", showStats.ToString());
- SetSetting(this, "reminder" , reminder);
- SetSetting(this, "guideStartTime" , guideStartTime);
- SetSetting(this, "schedule" , schedule);
- SetSetting(this, "recordingQuality" , recordingQuality);
- SetSetting(this, "showDescription" , showDescription.ToString());
- SetSetting(this, "showSubtitle" , showSubtitle.ToString());
- SetSetting(this, "showGenre" , showGenre);
- SetSetting(this, "showRating" , showRating.ToString());
- SetSetting(this, "showNew" , showNew.ToString());
- SetSetting(this, "showHD" , showHD.ToString());
- SetSetting(this, "showIMDB" , showIMDB.ToString());
- SetSetting(this, "showNetflix" , showNetflix.ToString());
- SetSetting(this, "showTVCom" , showTVCom.ToString());
- SetSetting(this, "showWiki" , showWiki.ToString());
- SetSetting(this, "showCredits" , showCredits.ToString());
- SetSetting(this, "showAirDate" , showAirDate.ToString());
- SetSetting(this, "showStarRating" , showStarRating.ToString());
- SetSetting(this, "playlistExtnesion" , playlistExtension);
- SetSetting(this, "autologinNetworks" , autologinNetworks);
- SetSetting(this, "GuestUser" , GuestUser);
- SetSetting(this, "GuestPassword" , GuestPassword);
-
- SetSetting(this, "strmPlayer", strmPlayer);
- SetSetting(this, "strmExternal", strmExternal.ToString());
- SetSetting(this, "strmVLCLoc", strmVLCLoc);
- SetSetting(this, "strmPort", strmPort.ToString());
- SetSetting(this, "strmBuffer", strmBuffer.ToString());
- SetSetting(this, "strmPriority", strmPriority);
- SetSetting(this, "strmBitRate", strmBitRate.ToString());
- SetSetting(this, "strmVideoSizeOpt", strmVideoSizeOpt);
- SetSetting(this, "strmVideoSize", strmVideoSize);
- SetSetting(this, "strmVideoScaleSize", strmVideoScaleSize);
- SetSetting(this, "strmSetting", strmSetting);
- SetSetting(this, "strmMux", strmMux);
- SetSetting(this, "strmVideo", strmVideo);
- SetSetting(this, "strmAudio", strmAudio);
- SetSetting(this, "strmAudoBitrate", strmAudoBitrate);
- SetSetting(this, "strmAudioChannels", strmAudioChannels);
- SetSetting(this, "strmVEncoder", strmVEncoder);
-
- SetSetting(this, "strmH264KeyInt", strmH264KeyInt);
- SetSetting(this, "strmH264IDRInt", strmH264IDRInt);
- SetSetting(this, "strmH264BFrames", strmH264BFrames);
- SetSetting(this, "strmH264QuantizerParam", strmH264QuantizerParam);
- SetSetting(this, "strmH264QuantizerMax", strmH264QuantizerMax);
- SetSetting(this, "strmH264QuantizerMin", strmH264QuantizerMin);
- SetSetting(this, "strmH264CABAC", strmH264CABAC.ToString());
- SetSetting(this, "strmH264LoopFilter", strmH264LoopFilter.ToString());
- SetSetting(this, "strmH264Analyse", strmH264Analyse.ToString());
- SetSetting(this, "strmH264FrameRef", strmH264FrameRef);
- SetSetting(this, "strmH264Adapt", strmH264Adapt);
- SetSetting(this, "strmH264Me", strmH264Me);
- SetSetting(this, "strmH264SubME", strmH264SubME);
- SetSetting(this, "strmH264ChromaME", strmH264ChromaME);
- SetSetting(this, "strmH264MERange", strmH264MERange);
-
- SetSetting(this, "strmPlayer2", strmPlayer2);
- SetSetting(this, "strmExternal2", strmExternal2.ToString());
- SetSetting(this, "strmVLCLoc2", strmVLCLoc2);
- SetSetting(this, "strmPort2", strmPort2.ToString());
- SetSetting(this, "strmBuffer2", strmBuffer2.ToString());
- SetSetting(this, "strmPriority2", strmPriority2);
- SetSetting(this, "strmBitRate2", strmBitRate2.ToString());
- SetSetting(this, "strmVideoSizeOpt2", strmVideoSizeOpt2);
- SetSetting(this, "strmVideoSize2", strmVideoSize2);
- SetSetting(this, "strmVideoScaleSize2", strmVideoScaleSize2);
- SetSetting(this, "strmSetting2", strmSetting2);
- SetSetting(this, "strmMux2", strmMux2);
- SetSetting(this, "strmVideo2", strmVideo2);
- SetSetting(this, "strmAudio2", strmAudio2);
- SetSetting(this, "strmAudoBitrate2", strmAudoBitrate2);
- SetSetting(this, "strmAudioChannels2", strmAudioChannels2);
- SetSetting(this, "strmVEncoder2", strmVEncoder2);
-
- SetSetting(this, "strmH264KeyInt2", strmH264KeyInt2);
- SetSetting(this, "strmH264IDRInt2", strmH264IDRInt2);
- SetSetting(this, "strmH264BFrames2", strmH264BFrames2);
- SetSetting(this, "strmH264QuantizerParam2", strmH264QuantizerParam2);
- SetSetting(this, "strmH264QuantizerMax2", strmH264QuantizerMax2);
- SetSetting(this, "strmH264QuantizerMin2", strmH264QuantizerMin2);
- SetSetting(this, "strmH264CABAC2", strmH264CABAC2.ToString());
- SetSetting(this, "strmH264LoopFilter2", strmH264LoopFilter2.ToString());
- SetSetting(this, "strmH264Analyse2", strmH264Analyse2.ToString());
- SetSetting(this, "strmH264FrameRef2", strmH264FrameRef2);
- SetSetting(this, "strmH264Adapt2", strmH264Adapt2);
- SetSetting(this, "strmH264Me2", strmH264Me2);
- SetSetting(this, "strmH264SubME2", strmH264SubME2);
- SetSetting(this, "strmH264ChromaME2", strmH264ChromaME2);
- SetSetting(this, "strmH264MERange2", strmH264MERange2);
-
- SaveToFile();
- }
-
- public string[] ParseAutologinNetworks()
- {
- ArrayList invalidAutologinNetworks = new ArrayList();
- autologinNets = new IPList();
- if (autologinNetworks.Length > 0)
- {
- foreach (string autologinNetwork in autologinNetworks.Split(','))
- {
- if (autologinNetwork.ToLower() == "none") continue;
- try
- {
- string[] networkDetails = autologinNetwork.Split('/');
- if (networkDetails.Length == 1)
- {
- autologinNets.Add(networkDetails[0]);
- }
- else if (networkDetails.Length == 2)
- {
- int parts = networkDetails[1].Split('.').Length;
- if (parts == 1)
- {
- autologinNets.Add(networkDetails[0], Convert.ToInt32(networkDetails[1]));
- }
- else if (parts == 4)
- {
- autologinNets.Add(networkDetails[0], networkDetails[1]);
- }
- else
- {
- invalidAutologinNetworks.Add(autologinNetwork);
- }
- }
- else
- {
- invalidAutologinNetworks.Add(autologinNetwork);
- }
- }
- catch
- {
- invalidAutologinNetworks.Add(autologinNetwork);
- }
- }
- }
- return (string[])invalidAutologinNetworks.ToArray(typeof(string));
- }
-
- private static string versionToolTip;
- public string GetVersionToolTip()
- {
- if (versionToolTip == null)
- {
- Assembly me = Assembly.GetExecutingAssembly();
- string configuration = ((AssemblyConfigurationAttribute)me.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false)[0]).Configuration;
- string version = me.GetName().Version.ToString(2);
- XmlDocument changeLog = new XmlDocument();
- changeLog.Load(HttpContext.Current.Server.MapPath("~/public/ChangeLog.xml"));
- string[] revision = changeLog.SelectSingleNode("/changelog/@commit_revision").Value.Split(new char[] {' ', '$'});
- versionToolTip = "GB-PVR web server, " + configuration + ", version: " + version + "." + revision[2];
- }
- return versionToolTip;
- }
-
- #region Private Variables
-
- private HybridDictionary globalSettings;
- private string webConfigFileName;
- private XmlDocument configWeb;
-
- #endregion
-
- #region Public Global Settings Methods
-
- public string GetSetting(object moduleObject, string settingName)
- {
- string moduleName = "gbweb";
-
- //Logger.Verbose("RecorderHelperConfig: GetSetting(" + moduleName + ", " + settingName + ")");
-
- LoadFromFile(false);
-
- XmlNode globalSettingsNode = (XmlNode)globalSettings[moduleName];
-
- if (globalSettingsNode == null) return null;
-
- XmlNode settingNode = globalSettingsNode.SelectSingleNode(settingName);
-
- if (settingNode == null) return null;
-
- return settingNode.InnerText;
- }
-
- public void SetSetting(object moduleObject, string settingName, string value)
- {
- string moduleName = "gbweb";
-
- //Logger.Verbose("RecorderHelperConfig: SetSetting(" + moduleName + ", " + settingName + ")");
-
- XmlNode globalSettingsNode = (XmlNode)globalSettings[moduleName];
-
- if (globalSettingsNode == null)
- {
- globalSettingsNode = configWeb.CreateElement(moduleName);
- globalSettings[moduleName] = globalSettingsNode;
- }
-
- XmlNode settingNode = globalSettingsNode.SelectSingleNode(settingName);
-
- if (settingNode == null)
- {
- settingNode = configWeb.CreateElement(settingName);
- globalSettingsNode.AppendChild(settingNode);
- }
-
- settingNode.InnerText = value;
- }
-
- public void SaveSettings()
- {
- SaveToFile();
- }
-
- #endregion
-
- #region Private Methods
-
- private void LoadFromFile(bool reload)
- {
- if (!reload && (configWeb != null)) return;
-
- Logger.Verbose("RecorderHelperConfig: LoadFromFile()");
-
- configWeb = new XmlDocument();
-
- if (File.Exists(GetWebConfigFileName()))
- configWeb.Load(GetWebConfigFileName());
-
- globalSettings = new HybridDictionary();
-
- foreach (XmlNode globalSettingsNode in configWeb.SelectNodes("settings/globalSettings/*"))
- {
- globalSettings[globalSettingsNode.Name] = globalSettingsNode;
- }
-
- }
-
- private void SaveToFile()
- {
- Logger.Verbose("RecorderHelperConfig: SaveToFile()");
-
- configWeb.RemoveAll();
-
- configWeb.AppendChild(configWeb.CreateXmlDeclaration("1.0", "UTF-8", null));
-
- XmlNode settings = configWeb.CreateElement("settings");
- configWeb.AppendChild(settings);
-
- XmlNode global = configWeb.CreateElement("globalSettings");
- settings.AppendChild(global);
-
- ArrayList globalSettingsKeys = new ArrayList(globalSettings.Keys);
- globalSettingsKeys.Sort();
- foreach (string globalSettingKey in globalSettingsKeys)
- {
- global.AppendChild((XmlNode)globalSettings[globalSettingKey]);
- }
-
- configWeb.Save(GetWebConfigFileName());
- }
-
- private string GetWebConfigFileName()
- {
- if (webConfigFileName == null)
- {
- webConfigFileName = Path.Combine(GetInstallDir(), "config-web.xml");
- }
- return webConfigFileName;
- }
-
- public string GetInstallDir()
- {
- // determine install location
- string installDirectory = @"c:\program files\devnz\gbpvr\";
- try
- {
- using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\devnz\"))
- {
- string temp = (string)key.GetValue("GBPVR InstallDir");
- if (temp != null)
- {
- installDirectory = temp;
- }
- }
- }
- catch (Exception ex)
- {
- Logger.Error("Error reading install location from registry: " + ex.ToString());
- }
- return installDirectory;
- }
-
- #endregion
-
- }
- }
-